//
//  BaseTableViewController.swift
//  weiboSwift
//
//  Created by 龚欣 on 15/6/24.
//  Copyright © 2015年 gong. All rights reserved.
//

import UIKit

class BaseTableViewController: UITableViewController,VisitorViewDelegate {

    var isLogin = false
    var visitorView : VisitorView?
    override func loadView() {
       
        isLogin = sharedAccount != nil
        
     
        isLogin ? super.loadView() : setVisitorView()
    }
    
    func setVisitorView(){
        visitorView = VisitorView()
        visitorView?.delegate = self
        view = visitorView
        navigationItem.leftBarButtonItem = UIBarButtonItem(title: "注册", style: UIBarButtonItemStyle.Plain, target: self, action: "visitorViewRegistorButtonClick")
        navigationItem.rightBarButtonItem = UIBarButtonItem(title: "登陆", style: UIBarButtonItemStyle.Plain, target: self, action: "visitorViewLoginButtonClick")
    }
    
    func visitorViewLoginButtonClick() {
        print("login")
        
        let vc = OAuthViewController()
        let naiv = UINavigationController(rootViewController: vc)
        presentViewController(naiv, animated: true, completion: nil)
        
    }
    
    func visitorViewRegistorButtonClick() {
        print("registor")
    }
    
    override func viewDidLoad() {
        super.viewDidLoad()
  
    }
  
    func changeView(){
       visitorView?.hidden = true
    }

   
}
